#include "bcp.h"
#ifdef BLE_BSP
#include "ble.h"
#endif

#ifdef ENABLE_BSP

uint8 databuf[30];
uint16 BcpBuf[30];


#ifdef BLE_BSP
//////////////////////////////////////////////////////////////////////////////
/// \brief			Hal_bcp_ble_Send
/// \param			none
/// \return 			none
/// \deprecated monitor uart  send use ble
///////////////////////////////////////////////////////////////////////////////
void Hal_bcp_ble_Send(uint8 *buf,uint8 len)
{
    CYBLE_API_RESULT_T apiResult;
    CYBLE_GATT_HANDLE_VALUE_PAIR_T CustomNotificationhandle;
  
		CustomNotificationhandle.attrHandle = UART_TX_HANDLE;
		CustomNotificationhandle.value.val = buf;
		CustomNotificationhandle.value.len = len;
		CustomNotificationhandle.value.actualLen = len;
#if 1

		/* Send notification to client using previously filled structure */
		apiResult = CyBle_GattsNotification(cyBle_connHandle, &CustomNotificationhandle);
#else

		apiResult = CyBle_GattcWriteWithoutResponse(cyBle_connHandle,&CustomNotificationhandle);
#endif
		Ble_ProcessEvents();

}
#endif

void Hal_bcp_uart_Send(uint8 *pdat,uint8 num)
{
  uint8 i;

	
  for(i=0;i<num;i++)
  {
		//Debug_Uart_SpiUartWriteTxData(*(pdat+i));

		//Debug_Uart_UartPutChar(*(pdat+i));
    
    SW_Tx_UART_PutChar(*(pdat+i));
  }
}



void Bcp_Show(uint16 *buf,uint8 len)
{
    uint8 i,j;

		databuf[0] = 0xAA;
		
		for(i=0,j=1;i<len;i++,j+=2)
			{
				databuf[j] = HI8(buf[i]);
				databuf[j+1] = LO8(buf[i]);
			}
#ifdef UART_BSP
    Hal_bcp_uart_Send(databuf,(len*2+1));
#elif defined(BLE_BSP)
		Hal_bcp_ble_Send(databuf,(len*2+1));

#endif
}

void Bcp_Start(void)
{
#ifdef UART_BSP
#if(SW_Tx_UART_PIN_STATIC_MODE == 1u)
				SW_Tx_UART_Start() ;
#else
				SW_Tx_UART_StartEx(BCP_UART_PORT,BCP_UART_PIN);
#endif /* (SW_Tx_UART_PIN_STATIC_MODE == 1u) */

#endif
}


#endif


